/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 */

package com.xci.edu.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.github.lvyanyang.core.BaseEntity;
import com.github.lvyanyang.core.Const;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 考试预约
 * @author 马星俊 maxingjun@xci96716.com
 * @since 2020-11-24 18:00:15
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "考试预约")
public class ExamPre extends BaseEntity {
    /**
     * 
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ExcelIgnore
    @Excel(name = "", width = 20d)
    @ApiModelProperty(value = "", position = 1)
    private Long id;

    /**
     * 学员主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "学员主键不能为空")
    @Excel(name = "学员主键", width = 20d)
    @ApiModelProperty(value = "学员主键", required = true, position = 2)
    private Long studentId;

    /**
     * 学员姓名
     */
    @NotBlank(message = "学员姓名不能为空")
    @Length(max = 50, message = "学员姓名长度不能超过{max}个字符")
    @Excel(name = "学员姓名", width = 20d)
    @ApiModelProperty(value = "学员姓名", required = true, position = 3)
    private String studentName;

    /**
     * 考试开始时间
     */
    @NotNull(message = "考试开始时间不能为空")
    @Excel(name = "考试开始时间", width = 20d, exportFormat = Const.DEFAULT_DATETIME_PATTERN)
    @ApiModelProperty(value = "考试开始时间", required = true, position = 4)
    private Date examStartDate;

    /**
     * 考试结束时间
     */
    @NotNull(message = "考试结束时间不能为空")
    @Excel(name = "考试结束时间", width = 20d, exportFormat = Const.DEFAULT_DATETIME_PATTERN)
    @ApiModelProperty(value = "考试结束时间", required = true, position = 5)
    private Date examEndDate;

    /**
     * 试卷主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "试卷主键不能为空")
    @Excel(name = "试卷主键", width = 20d)
    @ApiModelProperty(value = "试卷主键", required = true, position = 6)
    private Long paperId;

    /**
     * 试卷名称
     */
    @NotBlank(message = "试卷名称不能为空")
    @Length(max = 50, message = "试卷名称长度不能超过{max}个字符")
    @Excel(name = "试卷名称", width = 20d)
    @ApiModelProperty(value = "试卷名称", required = true, position = 7)
    private String paperName;

    /**
     * 可考次数
     */
    @NotNull(message = "可考次数不能为空")
    @Excel(name = "可考次数", width = 20d)
    @ApiModelProperty(value = "可考次数", required = true, position = 8)
    private Integer usableCount;

    /**
     * 预约类型[0-正常, 1-补考]
     */
    @NotNull(message = "预约类型 不能为空")
    @Excel(name = "预约类型 ", width = 20d, replace = { "正常_0", "补考_1" })
    @ApiModelProperty(value = "预约类型[0-正常, 1-补考] ", required = true, position = 9)
    private Integer preCategory;
    /**
     * 预约类型名称
     */
    @Excel(name = "预约类型名称", width = 20d)
    @ApiModelProperty(value = "预约类型名称", position = 9)
    private String preCategoryName;

    /**
     * 预约类型名称
     */
    public String getPreCategoryName(){
        switch(preCategory) {
            case 0:
                return "正常";
            case 1:
                return "补考";
        }
        return Const.Empty;
    }
    /**
     * 状态[1-启用, 0-禁用]
     */
    @NotNull(message = "状态不能为空")
    @Excel(name = "状态", width = 20d, replace = { "启用_1", "禁用_0" })
    @ApiModelProperty(value = "状态[1-启用, 0-禁用]", required = true, position = 10)
    private Integer status;

    /**
     * 操作时间
     */
//    @NotNull(message = "操作时间不能为空")
    @Excel(name = "操作时间", width = 20d, exportFormat = Const.DEFAULT_DATETIME_PATTERN)
    @ApiModelProperty(value = "操作时间", required = true, position = 11)
    private Date operateDateTime;

    /**
     * 备注
     */
    @Length(max = 500, message = "备注长度不能超过{max}个字符")
    @Excel(name = "备注", width = 20d)
    @ApiModelProperty(value = "备注", position = 12)
    private String remark;

    @Override
    public String toString() {
        return "ExamPre{" +
                "id=" + id +
                ", studentId=" + studentId +
                ", studentName='" + studentName + '\'' +
                ", examStartDate=" + examStartDate +
                ", examEndDate=" + examEndDate +
                ", paperId=" + paperId +
                ", paperName='" + paperName + '\'' +
                ", usableCount=" + usableCount +
                ", preCategory=" + preCategory +
                ", preCategoryName='" + preCategoryName + '\'' +
                ", status=" + status +
                ", operateDateTime=" + operateDateTime +
                ", remark='" + remark + '\'' +
                '}';
    }
}